<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- vue自定义属性不能使用驼峰命名 -->
        <child :tstr="str" :game-arr="arr"></child>
    </div>
    <script src="./vue.js"></script>
    <script>

        const child = {
            // props: ['tstr', 'gameArr'],
            props: {
                // tstr: String,
                // gameArr: Array,
                // tstr: {
                //     type: String, 
                //     required: true // 值为true表示必须传递该属性
                // },
                tstr:{
                    type: String,
                    default: 'hello world'
                },
                gameArr: {
                    type: Array,
                    default: () => {
                        return []
                    }
                }
            },
            template: `
                <div>
                    这是个子组件
                    {{tstr}}
                    <ul>
                        <li v-for="item in gameArr">{{item}}</li>
                    </ul>
                </div>
            `,
            data() {
                return {

                }
            }
        }

        new Vue({
            el: "#app",
            components: { // 组件局部注册
                child
            },

            data: {
                str: '123',
                arr: ['英雄联盟', '王者荣耀', '原神']
            }
        })
    </script>
</body>
</html>